package com.huazhi.wzsnw.service.impl;

import com.huazhi.wzsnw.mapper.UserMapper;
import com.huazhi.wzsnw.model.User;
import com.huazhi.wzsnw.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public int save(User record) {
        userMapper.insertSelective(record);
        return 0;
    }

    @Override
    public int delete(User record) {
        userMapper.deleteByPrimaryKey(record.getTid());
        return 0;
    }

    @Override
    public int deletes(List<User> records) {
        for(User record:records){
            delete(record);
        }
        return 0;
    }

    @Override
    public int update(User record) {
        userMapper.updateByPrimaryKeySelective(record);
        return 0;
    }

    @Override
    public List<User> findPagingByListTid(List<String> stringList, Integer pageIndex, Integer pageSize) {
        return userMapper.findPagingByListTid(stringList,pageIndex,pageSize);
    }

    @Override
    public User findByTid(String tid) {
        return  userMapper.selectByPrimaryKey(tid);
    }

    @Override
    public User findByField(String field, String value) {
        return userMapper.selectUserByField(field,value);
    }

    @Override
    public User getUserByTidPassword(String tid, String password) {
        return userMapper.selectUserByTidPassword(tid,password);
    }

    @Override
    public List<String> getListTidBySearch(String key,  List<String> userList) {
        return userMapper.selectListTidBySearch(key,userList);
    }

    @Override
    public List<User> getUserList() {
        return userMapper.selectUserList();
    }


}
